package org.spindle.soasuite;

import org.spindle.soasuite.data.util.HibernateUtil;
import org.spindle.soasuite.manager.SOAManager;
import org.spindle.soasuite.transformer.TransformerFactory;
import org.spindle.soasuite.transformer.api.IWebTransformer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WebController extends HttpServlet {

    private SOAManager manager;
    private IWebTransformer transformer;

    @Override
    public void init() throws ServletException {
        super.init();
        manager = new SOAManager();
        transformer = TransformerFactory.getJSONTransformer();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String command = request.getParameter("c");

        if (command == null || command.equals("")) {

        }


        response.setContentType(transformer.getContentType());
        response.getWriter().print(transformer.toJSON(manager.execute("test")));
        response.getWriter().flush();

    }


}
